home *** CD-ROM | disk | FTP | other *** search
- // --- VARS ---
-
- var widgetVersion = "1.1";
- var widgetVersionPage = "http://www.bewidget.com/widget_version.php?widget=CheckDomain";
-
- var registrar = 0;
-
- var registered = 0; //0:visit | 1:whois
-
- var okay = true;
- var err = "";
-
- var registrars = new Array("GoDaddy", "Dotster", "1&1", "NetFirms", "BuyDomains", "iPower");
-
- // --- UPDATES ---
-
- function hideUpdate(){
- document.getElementById("update").style.display = "none";
- }
-
- function swImg(elt, newsrc){
- elt.src = newsrc;
- }
-
- function checkForUpdates(){
- var req = new XMLHttpRequest();
- req.onreadystatechange = function(){
- if (req.readyState == 4) {
- if (req.status == 200) {
-
- string = req.responseText;
- if(string != widgetVersion && string != ""){
- document.getElementById("update").style.display = "block";
- }else{
- return false;
- }
-
- }
- }
- }
-
- req.open("GET", widgetVersionPage, true);
- req.send("");
- }
-
-
- function setup(){
-
- if(loadPref('registrar') != null){
- registrar = loadPref('registrar');
- }
-
- if(loadPref('registered') != null){
- registered = loadPref('registered');
- }
-
- document.getElementById("avail").selectedIndex = registrar;
- document.getElementById("unavail").selectedIndex = registered;
- checkForUpdates();
- }
-
- function availChange(){
- registrar = document.getElementById("avail").options[document.getElementById("avail").selectedIndex].value;
- savePref("registrar", registrar);
- }
-
- function unavailChange(){
- registered = document.getElementById("unavail").options[document.getElementById("unavail").selectedIndex].value;
- savePref("registered", registered);
- }
-
- function checkDomain(){
- restore();
- okay = true;
- domain = document.getElementById("domain_field").value;
-
- domain = trim(domain);
- document.getElementById("domain_field").value = domain;
-
- domain_validity = checkDV(domain);
- if(domain_validity == false){
- restore();
- okay = false;
- document.getElementById("status").innerHTML=err;
- return;
- }
-
- regex = /[\.]+/ig
- if(domain.match(regex)){
- splited = domain.split(".");
- domain = splited[0];
- document.getElementById("domain_field").value = domain;
- }
-
- document.getElementById("status").innerHTML="loading...";
- document.getElementById("com").src="images/com_off.png";
- document.getElementById("net").src="images/net_off.png";
- document.getElementById("org").src="images/org_off.png";
-
- //var url ="http://order.sbs.yahoo.com/ds/DomainSearchResults?d="+domain+"&.p=&m=dom&.src=sbs";
- var url = "https://secure.registerapi.com/order/register/check.php?siteid=42566&DomainName="+domain+"&comtld=.com&nettld=.net&orgtld=.org&x=5&y=6";
-
-
- req = new XMLHttpRequest();
- req.onreadystatechange = function(){
-
- if (req.readyState == 4) {
- // only if "OK"
- if (req.status == 200) {
-
- string = req.responseText;
-
-
- entries = /<span\sclass=\"(available|notavailable)\">[^<]+/ig
-
- if(string.match(entries)){
- matches = string.match(entries);
- alert(matches);
- alert(matches.length);
-
- avail = "available";
- notavail = "notavailable";
-
- var data = new Array();
-
- for(i=0;i<matches.length;i++){
- if(matches[i].match(notavail)){
- data[i] = 1;
- }else if(matches[i].match(avail)){
- data[i] = 0;
- }
- }
-
- }else{
- document.getElementById("status").innerHTML = "an error ocurred";
- return;
- }
-
- if(okay == true){
- if(data[0] == 0){
- thelink = getLink(domain, "com");
- document.getElementById("comlink").innerHTML="<a href=\"javascript:widget.openURL('"+thelink+"');\" title=\"register "+domain+".com\"><img id=\"com\" src=\"images/com_available.png\"></a>";
- }else{
- thelink = getULink(domain, "com");
- document.getElementById("comlink").innerHTML="<a href=\"javascript:widget.openURL('"+thelink+"');\" title=\"visit "+domain+".com\"><img id=\"com\" src=\"images/com_taken.png\"></a>";
- }
-
- if(data[1] == 0){
- thelink = getLink(domain, "net");
- document.getElementById("netlink").innerHTML="<a href=\"javascript:widget.openURL('"+thelink+"');\" title=\"register "+domain+".net\"><img id=\"net\" src=\"images/net_available.png\"></a>";
- }else{
- thelink = getULink(domain, "net");
- document.getElementById("netlink").innerHTML="<a href=\"javascript:widget.openURL('"+thelink+"');\" title=\"visit "+domain+".net\"><img id=\"net\" src=\"images/net_taken.png\"></a>";
- }
-
- if(data[2] == 0){
- thelink = getLink(domain, "org");
- document.getElementById("orglink").innerHTML="<a href=\"javascript:widget.openURL('"+thelink+"');\" title=\"register "+domain+".org\"><img id=\"org\" src=\"images/org_available.png\"></a>";
- }else{
- thelink = getULink(domain, "org");
- document.getElementById("orglink").innerHTML="<a href=\"javascript:widget.openURL('"+thelink+"');\" title=\"visit "+domain+".org\"><img id=\"org\" src=\"images/org_taken.png\"></a>";
- }
-
- document.getElementById("status").innerHTML="";
- }
- } else {
- document.getElementById("status").innerHTML ="error: "+req.status;
- }
- }
- }
-
- req.open("GET", url, true);
- req.send("");
-
- }
-
- function restore(){
-
- document.getElementById("status").innerHTML="";
- document.getElementById("comlink").innerHTML="<a href=\"\" title=\"\"><img id=\"com\" src=\"images/com_off.png\"></a>";
- document.getElementById("netlink").innerHTML="<a href=\"\" title=\"\"><img id=\"net\" src=\"images/net_off.png\"></a>";
- document.getElementById("orglink").innerHTML="<a href=\"\" title=\"\"><img id=\"org\" src=\"images/org_off.png\"></a>";
-
- }
-
-
- function checkDV(domain){
-
- if(domain.length == 0){
- err = "";
- return false;
- }
-
- regex = /[a-zA-Z0-9-\.]/g
- if(domain.match(regex)){
- matches = domain.match(regex);
- if(matches.length != domain.length){
- err = "syntax error";
- return false;
- }
- }else{
- return false;
- }
-
- regex = /[\.\-]+$/g
- if(domain.match(regex)){
- err = "syntax error";
- return false;
- }
-
- return true;
-
- }
-
-
- function trim(string){
-
- string = string.replace(/\s+/g, "");
- return string;
-
- }
-
-
- function getLink(domain, tld){
-
- if(registrar == 1){
- return "http://www.kqzyfj.com/interactive?DomainName="+domain+"."+tld+"&siteid=4798&submit=GO&pid=1960393&url=https://secure.registerapi.com/DDS/controller.php&aid=5463237";
- }
-
- if(registrar == 3){
- return "http://www.kqzyfj.com/interactive?oldstage=ext&newstage=modify&postrun=1&verifypost=1&domainsignup=1&suhosting=hostingbasic&domainproduct=domain1yr&domainname="+domain+"&tld="+tld+"&submit=submit&pid=1960393&url=https://secure.netfirms.com/signup/stage/summary/hostingplan/basic/domaintype/1yearregistration&aid=10381702";
- }
-
- if(registrar == 2){
- return "http://www.tkqlhce.com/interactive?__currentindex[domaincheck]=0&__sendingdata=1&__pageflow=Order&multicheck.Domain="+domain+"&multicheck.Tlds="+tld+"&pid=1960393&url=http://order.1and1.com/xml/order/domaincheck?ac=OM.US.US469K02463T2103a&aid=10376103";
- }
-
- if(registrar == 0){
- return "http://www.kqzyfj.com/click?AID=10390987&PID=1960393&url=http://www.godaddy.com/gdshop/registrar/search.asp?isc=0000000000&domainToCheck="+domain+"&tld=."+tld+"&checkAvail=1&submit=submit";
- }
-
- if(registrar == 4){
- return "http://www.kqzyfj.com/click?AID=10429673&PID=1960393&url=http://www.buydomains.com/home.jsp?referrer_id=4052";
- }
-
- if(registrar == 5){
- return "http://www.anrdoezrs.net/click?AID=10392398&PID=1960393&url=http://www.ipower.com/";
- }
- }
-
-
- function getULink(domain, tld){
-
- if(registered == 0){
- return "http://www."+domain+"."+tld;
- }
-
- if(registered == 1){
- return "http://www.checkdomain.com/cgi-bin/checkdomain.pl?domain="+domain+"."+tld;
- }
-
- }
-
-
- /*********************************/
- // HIDING AND SHOWING PREFERENCES
- /*********************************/
-
- // showPrefs() is called when the preferences flipper is clicked upon. It freezes the front of the widget,
- // hides the front div, unhides the back div, and then flips the widget over.
- var hidingprefs=false;
-
- function showPrefs()
- {
- window.resizeTo(258,138);
- var front = document.getElementById("front");
- var back = document.getElementById("back");
-
- if (window.widget)
- widget.prepareForTransition("ToBack"); // freezes the widget so that you can change it without the user noticing
-
- front.style.display="none"; // hide the front
- back.style.display="block"; // show the back
-
- if (window.widget)
- setTimeout ('widget.performTransition();', 0); // and flip the widget over
-
- document.getElementById('fliprollie').style.display = 'none'; // clean up the front side - hide the circle behind the info button
-
- }
-
-
- // hidePrefs() is called by the done button on the back side of the widget. It performs the opposite transition
- // as showPrefs() does.
-
- function hidePrefs()
- {
-
- var front = document.getElementById("front");
- var back = document.getElementById("back");
-
- if (window.widget)
- widget.prepareForTransition("ToFront"); // freezes the widget and prepares it for the flip back to the front
-
- back.style.display="none"; // hide the back
- front.style.display="block"; // show the front
-
- window.resizeTo(258,108);
-
- if (window.widget)
- setTimeout ('widget.performTransition();', 0); // and flip the widget back to the front
- hidingprefs=true;
- }
-
-
- // PREFERENCE BUTTON ANIMATION (- the pref flipper fade in/out)
-
- var flipShown = false; // a flag used to signify if the flipper is currently shown or not.
-
-
- // A structure that holds information that is needed for the animation to run.
- var animation = {duration:0, starttime:0, to:1.0, now:0.0, from:0.0, firstElement:null, timer:null};
-
-
- // mousemove() is the event handle assigned to the onmousemove property on the front div of the widget.
- // It is triggered whenever a mouse is moved within the bounds of your widget. It prepares the
- // preference flipper fade and then calls animate() to performs the animation.
-
- function mousemove (event)
- {
- if (!flipShown) // if the preferences flipper is not already showing...
- {
- if (animation.timer != null) // reset the animation timer value, in case a value was left behind
- {
- clearInterval (animation.timer);
- animation.timer = null;
- }
-
- var starttime = (new Date).getTime() - 13; // set it back one frame
-
- animation.duration = 500; // animation time, in ms
- animation.starttime = starttime; // specify the start time
- animation.firstElement = document.getElementById ('flip'); // specify the element to fade
- animation.timer = setInterval ("animate();", 13); // set the animation function
- animation.from = animation.now; // beginning opacity (not ness. 0)
- animation.to = 1.0; // final opacity
- animate(); // begin animation
- flipShown = true; // mark the flipper as animated
- }
- }
-
- // mouseexit() is the opposite of mousemove() in that it preps the preferences flipper
- // to disappear. It adds the appropriate values to the animation data structure and sets the animation in motion.
-
- function mouseexit (event)
- {
- if (flipShown)
- {
- // fade in the flip widget
- if (animation.timer != null)
- {
- clearInterval (animation.timer);
- animation.timer = null;
- }
-
- var starttime = (new Date).getTime() - 13;
-
- animation.duration = 500;
- animation.starttime = starttime;
- animation.firstElement = document.getElementById ('flip');
- animation.timer = setInterval ("animate();", 13);
- animation.from = animation.now;
- animation.to = 0.0;
- animate();
- flipShown = false;
- }
- }
-
-
- // animate() performs the fade animation for the preferences flipper. It uses the opacity CSS property to simulate a fade.
-
- function animate()
- {
- var T;
- var ease;
- var time = (new Date).getTime();
-
-
- T = limit_3(time-animation.starttime, 0, animation.duration);
-
- if (T >= animation.duration)
- {
- clearInterval (animation.timer);
- animation.timer = null;
- animation.now = animation.to;
- }
- else
- {
- ease = 0.5 - (0.5 * Math.cos(Math.PI * T / animation.duration));
- animation.now = computeNextFloat (animation.from, animation.to, ease);
- }
-
- animation.firstElement.style.opacity = animation.now;
- if(hidingprefs==true){
- hidingprefs=false;
- }
- }
-
-
- // these functions are utilities used by animate()
-
- function limit_3 (a, b, c)
- {
- return a < b ? b : (a > c ? c : a);
- }
-
- function computeNextFloat (from, to, ease)
- {
- return from + (to - from) * ease;
- }
-
- // these functions are called when the info button itself receives onmouseover and onmouseout events
-
- function enterflip(event)
- {
- document.getElementById('fliprollie').style.display = 'block';
- }
-
- function exitflip(event)
- {
- document.getElementById('fliprollie').style.display = 'none';
- }
-
- // --- PREFS ---
- //
- // example:
- // savePref('widgetHeight", 540);
- // loadPref("widgetHeight");
-
- function savePref(name, value){
- if(window.widget){
- widget.setPreferenceForKey(value, createKey(name));
- }
- }
-
- function createKey(keyName) {
- return (widget.identifier + '-' + keyName);
- }
-
- function loadPref(name){
- if(window.widget){
- value = widget.preferenceForKey(createKey(name));
- return value;
- }
- }